package android.slc.appbase.utils;

import android.slc.appbase.service.BaseInfoService;
import android.slc.commonlibrary.util.compat.SlcCrashUtils;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ServiceUtils;
import com.blankj.utilcode.util.ThreadUtils;

public class OnCrashListenerImp implements SlcCrashUtils.OnCrashListener {
    @Override
    public void onCrash(String crashInfo, Throwable e, SlcCrashUtils.OnNotifyUncaughtExceptionListener onNotifyUncaughtExceptionListener) {
        LogUtils.e(e);
        ServiceUtils.stopService(BaseInfoService.class);
        ActivityUtils.finishAllActivities();
        ThreadUtils.runOnUiThreadDelayed(() -> {
            android.os.Process.killProcess(android.os.Process.myPid());
            System.exit(0);
        }, 512);
    }
}